package com.github.chain.admin.api.controller;

import com.github.chain.admin.client.AdminLoggerServiceClient;
import com.github.chain.admin.common.domain.AdminLogger;
import com.github.framework.core.page.DataPage;
import com.github.chain.admin.common.request.AdminLoggerRequest;
import com.github.framework.core.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author AIQ
 * @date 2023/5/25
 * @project er-trader
 */
@Controller
public class AdminLoggerController {

    @Resource
    private AdminLoggerServiceClient adminLoggerServiceClient;

    @GetMapping("/main/system/actionLog/index")
    @RequiresPermissions("system:actionLog:index")
    public String index(AdminLoggerRequest adminLoggerRequest, Model model){

        Result<DataPage<AdminLogger>> result = adminLoggerServiceClient.findLogByPage(adminLoggerRequest);
        if (result.isSuccess()){
            DataPage<AdminLogger> dataPage = result.getData();
            model.addAttribute("page", dataPage);
            model.addAttribute("list", dataPage.getDataList());
        }
        return "/manager/logger/index";
    }
}
